package com.xrjsj.stage.util;

import com.xrjsj.stage.bean.common.ResultBean;
import com.xrjsj.stage.constant.CommonEnum.ResultInfo;

public class ResultUtil {

    public static ResultBean<Object> success(Object obj){
        ResultBean<Object> result = new ResultBean<Object>();
        result.setCode(ResultInfo.SUCCESS.getCode());
        result.setMsg("操作成功");
        result.setData(obj);
        return result;
    }
    public static ResultBean<Object> success(){
        return success(null);
    }

    public static ResultBean<Object> success(Object obj, String message){
        ResultBean<Object> result = new ResultBean<Object>();
        result.setCode(ResultInfo.SUCCESS.getCode());
        result.setMsg(message);
        result.setData(obj);
        return result;
    }

    public static ResultBean<Object> error(Integer code, String msg){
        ResultBean<Object> result = new ResultBean<Object>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    public static ResultBean<Object> error(String msg){
        ResultBean<Object> result = new ResultBean<Object>();
        result.setCode(ResultInfo.UNKOWN_ERROT.getCode());
        result.setMsg(msg);
        return result;
    }
    public static ResultBean<Object> error(){
        ResultBean<Object> result = new ResultBean<Object>();
        result.setCode(ResultInfo.UNKOWN_ERROT.getCode());
        result.setMsg("操作失败");
        return result;
    }
}
